from wormbane.geometry import Vector

_planar_vectors = dict(northwest = Vector(-1, 1),
                       north = Vector(0, 1),
                       northeast = Vector(1, 1),
                       west = Vector(-1, 0),
                       east = Vector(1, 0),
                       southwest = Vector(-1, -1),
                       south = Vector(0, -1),
                       southeast = Vector(1, -1))

_spatial_vectors = dict(northwest = Vector(-1, 1, 0),
                        north = Vector(0, 1, 0),
                        northeast = Vector(1, 1, 0),
                        west = Vector(-1, 0, 0),
                        east = Vector(1, 0, 0),
                        southwest = Vector(-1, -1, 0),
                        south = Vector(0, -1, 0),
                        southeast = Vector(1, -1, 0),
                        up = Vector(0, 0, 1),
                        down = Vector(0, 0, -1))

def is_direction(dir):
    return dir in _spatial_vectors

def is_horizontal_direction(dir):
    return dir in _planar_vectors

def is_vertical_direction(dir):
    return dir in ('up', 'down')

def direction_to_planar_vector(dir):
    return _planar_vectors[dir]

def is_spatial_direction(dir):
    return dir in _spatial_vectors

def direction_to_spatial_vector(dir):
    return _spatial_vectors[dir]

def is_cardinal_direction(dir):
    return dir in ('north', 'west', 'east', 'south')

def is_diagonal_direction(dir):
    return dir in ('northwest', 'northeast', 'southwest', 'southeast')
